<template>
  <div class="singleDiv" ref="singleDiv">
    <div class="singleName">
      <wave :percent="60"></wave>
      <div>
        <textarea rows="1" v-model="hostList.Internet" v-show="inteShow"></textarea>
        <textarea rows="1" v-model="hostList.intranet" v-show="intrShow"></textarea>
      </div>
    </div>
    <!-- 每一个图片 -->
    <div>
      <img :src="src" />
    </div>
  </div>
</template>

<script>
import { number } from 'echarts';
export default {
  components: {
    wave: () => import("@/components/system/wave.vue"),
  },
  props: {
    hostList: {
      required: true,
      type: String / number / Object,
    },
  },
  data () {
    // 这里存放数据
    return {
      inteShow: false,
      intrShow: false,
      percent: 10,
    };
  },
  // 监听属性 类似于data概念
  computed: {
    left: function () {
      return this.hostList.x + "px";
    },
    top: function () {
      return this.hostList.y + "px";
    },
    src: function () {
      let obj = {
        normal: "/static/image/board/board_normal.png",
        error: "/static/image/board/board_error.png",
        warning: "/static/image/board/board_warn.png",
      };
      return obj[this.hostList.status];
    },
  },
  mounted () {
    this.setUI();
  },
  methods: {
    setUI () {
      this.$refs["singleDiv"].style.setProperty("--left", this.left);
      this.$refs["singleDiv"].style.setProperty("--top", this.top);
      this.hostList.Internet ? (this.inteShow = true) : (this.inteShow = false);
      this.hostList.intranet ? (this.intrShow = true) : (this.intrShow = false);
    },
  },
};
</script>

<style  lang='scss' scoped>
.singleDiv {
  position: absolute;
  left: var(--left);
  top: var(--top);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center;
  font-size: 14px;
  font-weight: 400;
  z-index: 2;
}
// input内容框样式
.singleName {
  width: 152px;
  height: 40px;
  line-height: 40px;
  border-radius: 20px;
  background: #223d74;
  display: flex;
  align-items: center;
  color: #fff;
  textarea {
    margin-left: 2px;
    display: flex;
    width: 100px;
    resize: none;
    background: #223d74;
    border: none;
    color: #fff;
    text-align: center;
  }
}
</style>